 ////////////////////////////////////////////////////////////////
// filename: interface.h
// description: header file for Interface class
// author: Jay Tomten (jaytomten@gmail.com)
// notes:

// namespace
using namespace std;

// defines
#ifndef __INTERF__
#define __INTERF__

#define MENU_STATE_MM         929
#define MENU_STATE_LM         928
#define MENU_STATE_GM         930
#define MENU_STATE_OFF        931

#define SELECT_NEW_SOLO_GAME  999
#define SELECT_NEW_MULTI_GAME 987
#define SELECT_OPTIONS_MENU   990
#define SELECT_EXIT_GAME      998
#define SELECT_END_MATCH      997
#define SELECT_END_CONFIRM    988
#define SELECT_RESUME         989
#define SELECT_BUILD_MENU     991
#define SELECT_BUILD_INF      996
#define SELECT_BUILD_ENG      995
#define SELECT_BUILD_MED      994
#define SELECT_BUILD_EOD      993
#define SELECT_BUILD_SF       992

#define SELECT_CAMERA_LEFT    971
#define SELECT_CAMERA_RIGHT   972
#define SELECT_CAMERA_IN      973
#define SELECT_CAMERA_OUT     974

#define FONT_TITLE32          955
#define FONT_TITLE72          958
#define FONT_MAIN32           956
#define FONT_MAIN16           957

#define SPLASH_PRESENTS       901
#define SPLASH_LEVEL          902
#define SPLASH_RETREAT        903

// includes
#if defined(__APPLE__)
#include <SDL_ttf/SDL_ttf.h>
#else
#include <SDL/SDL_ttf.h>
#endif
#include <list>
#include <string>
#include "input.h"
#include "color.h"
#include "vertex.h"
#include "game.h"
#include "stats.h"

// globals

////////////////////////////////////////////////////////////////
// Interface - definition of our user interface class
class Interface {

public:

    int state;                              // the menu state
    int width;                              // screen width
    int height;                             // screen height

    Interface();                             // constructor
    ~Interface();                            // destructor

    bool Init(Game *e, int t, list<int> *l, Stats *s); // new, more simpler version
    bool Update(float d);                    // check for user input
    void Draw();                      // draw all Interface items

    void DrawImage2D(float x, float y, float z, GLuint *t, float w, float h);
    void DrawImage3D(float x, float y, float z, GLuint *t, float w, float h);
    void DrawString2D(float x, float y, float z, string s, int f);
    void DrawString3D(float x, float y, float z, string s, int f);
    void DrawSplash(float durration, float timer, int t, int extra);

    void Message(string mess, Color *c); // add a global game message (2d space)
    void Bubble(string mess, Vertex *position, Color *c); // add a popup character message bubble (3d space)

private:

    struct MenuItem {
        GLuint  tex; // texture
        Vertex  pos; // current position
        Vertex  des; // destination "home position"
        Vertex  sta; // starting point
        Color   col;
        float   wid; // texture width
        float   hei; // texture height
        bool    sel; // is this the selected item in the menu
        int     act; // what to do, the action to perform when selected
    };

    struct MessageItem {
        GLuint  tex; // texture
        Vertex  pos; // current position
        Vertex  des; // destination "home position"
        Vertex  sta; // starting point
        Color   col;
        float   wid; // texture width
        float   hei; // texture height
    };

    Game       *rEngine; // reference to the game engine
    int         player;  // the player type
    list<int>  *rEvents; // reference to player events to processes
    Stats      *rStats;

    TTF_Font *fontTitle32;
    TTF_Font *fontTitle72;
    TTF_Font *fontMain32;
    TTF_Font *fontMain16;

    GLuint fadetop; // a texture for backgrounds
    GLuint presents;
    GLuint retreat;

    list<MenuItem>    menu;  // main menu
    list<MessageItem> messages;  // in game messages
    list<MessageItem> bubble;  // character messages bubbles

    void BuildMenuItem(Vertex d, string s, int action, int m);

    bool Move(float d, list<MenuItem>::iterator i);
    bool Move(float d, list<MessageItem>::iterator i);

    void Go2D(); // switch to 2D mode
    void Go3D(); // go back to 3D mode

};

#endif
